﻿// ygrz.cpp: 实现文件
//

#include "pch.h"
#include "HoManSys1.h"
#include "ygrz.h"
#include "afxdialogex.h"
#include "ADOconnection.h"

// ygrz 对话框
ADOconnection con1;
IMPLEMENT_DYNAMIC(ygrz, CDialogEx)

ygrz::ygrz(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_ygrz, pParent)
	
	, m_stid(_T(""))
	, m_stname(_T(""))
	, m_idca(_T(""))
	, m_ph(_T(""))
{

}

ygrz::~ygrz()
{
}

void ygrz::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);

	DDX_Text(pDX, IDC_EDIT1, m_stid);
	DDX_Text(pDX, IDC_EDIT2, m_stname);
	DDX_Text(pDX, IDC_EDIT3, m_idca);
	
	DDX_Text(pDX, IDC_EDIT5, m_ph);
}


BEGIN_MESSAGE_MAP(ygrz, CDialogEx)
	ON_BN_CLICKED(IDOK, &ygrz::OnBnClickedOk)
	ON_BN_CLICKED(IDC_RADIO1, &ygrz::OnBnClickedRadio1)
	ON_BN_CLICKED(IDC_RADIO2, &ygrz::OnBnClickedRadio2)
END_MESSAGE_MAP()


// ygrz 消息处理程序


void ygrz::OnBnClickedOk()
{
	// TODO: 在此添加控件通知处理程序代码
	con1.DBConnection();
	CString s_sex;
	if (IsDlgButtonChecked(IDC_RADIO1))
		s_sex = _T("女");
	if (IsDlgButtonChecked(IDC_RADIO2))
		s_sex = _T("男");

	UpdateData();
	CString str = _T("insert into staff values('" + m_stid + "','" + m_stname + "','" + s_sex + "','" + m_idca + "','"+ m_ph + "')");
	_variant_t RecordsAffected;
	con1.m_pCon->Execute(_bstr_t(str), &RecordsAffected, adCmdText);
	MessageBox(_T("员工入职成功！"));
	CDialogEx::OnOK();
}



void ygrz::OnBnClickedRadio1()
{
	// TODO: 在此添加控件通知处理程序代码
}


void ygrz::OnBnClickedRadio2()
{
	// TODO: 在此添加控件通知处理程序代码
}


BOOL ygrz::OnInitDialog()
{
	CDialogEx::OnInitDialog();


	return TRUE;  // return TRUE unless you set the focus to a control
				  // 异常: OCX 属性页应返回 FALSE
}
